<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

// 'front.dev'
Route::group(['namespace' => 'Front', 'middleware' => ['front.dev', 'wechat.oauth', 'front.auth']], function() { 
    // 首页
    Route::get('/', 'HomeController@index')->name('home');
    Route::get('/home/fetchIndex', 'HomeController@fetchIndex')->name('homeFetch');
    Route::get('/home/recommend', 'HomeController@recommend')->name('homeRecommend');

    // 全国行情
    Route::get('/market', 'HomeController@market')->name('market');

    // 商品
    Route::get('market.html', 'ProductController@index')->name('product');
    Route::get('product/{id}.html', 'ProductController@show')->name('productShow');
    Route::get('product/detail/{id}', 'ProductController@fetchDetail')->name('product.fetchDetail');
    Route::get('product/list', 'ProductController@fetchList')->name('productListFetch'); //商品列表

    /**
     * 下单
     */
    Route::get('shopping/checkOut', 'ShoppingController@checkOut')->name('shopping.checkOut');
    Route::post('shopping/addCart', 'ShoppingController@addCart')->name('shopping.addCart');
    

    /**
     * 店铺订单管理
     */
    Route::get('member/shop/order', 'Member\Shop\OrderController@index')->name('member.shop.order'); // 订单列表
    Route::get('member/shop/order/{id}', 'Member\Shop\OrderController@show')->name('member.shop.show'); // 订单列表

    /**
     * 支付
     */
    Route::post('wxpay/{id}', 'ShoppingController@wxpay')->name('shopping.wxpay'); // 发起支付
    
    // 会员中心
    Route::get('member/userInfo', 'MemberController@userInfo')->name('userInfo'); // 用户信息
    Route::get('member', 'MemberController@index')->name('member');
    Route::get('member/order', 'MemberController@order')->name('memberOrder'); // 订单列表
    Route::get('member/orderList', 'OrderController@index')->name('fetchOrderList');
    Route::get('member/orderShow/{id}', 'MemberController@orderShow')->name('orderShow');
    Route::get('member/mstore', 'MemberController@mstore')->name('mstore');
    Route::get('member/mstore/product', 'MemberController@mstoreProduct')->name('member.mstoreProduct'); // 我发布的商品
    Route::post('member/mstore/product', 'MemberController@mstoreProductStore')->name('member.mstoreProductStore');
    Route::put('member/mstore/product/{id}', 'MemberController@mstoreProductUpdate')->name('member.mstoreProductStore');
    Route::delete('member/mstore/product/{id}', 'MemberController@mstoreProductDestory')->name('member.mstoreProductDestory');
    Route::get('member/mstore/productPreview/{id}', 'MemberController@mstoreProductPreview')->name('member.mstoreProductPreview'); // 我发布的商品预览
    Route::get('member/address/{action?}', 'MemberController@address')->name('member.address');
    Route::get('member/mstore/productCreate', 'MemberController@mstoreProductCreate')->name('productCreate');
    Route::get('member/mstore/productEdit/{id}', 'MemberController@mstoreProductEdit')->name('productEdit');
    Route::get('member/sold', 'MemberController@sold')->name('member.sold');
    Route::get('member/sold/{id}', 'MemberController@orderSoldShow')->name('member.orderSoldShow');
    Route::get('member/bankCard', 'MemberController@bankCard')->name('member.bankCard'); // 我的银行卡
    Route::post('member/bankCard', 'MemberController@bankCardStore')->name('member.bankCardStore'); // 银行卡认证
    Route::delete('member/bankCard', 'MemberController@bankCardDestroy')->name('member.bankCardDestroy'); // 银行卡认证

    /**
     * 我的认证
     */
    Route::get('member/certification', 'MemberController@certification')->name('member.certification'); // 我的认证
    Route::get('member/personalCert', 'MemberController@personalCert')->name('member.personalCert'); // 个人认证
    Route::post('member/personalCert', 'MemberController@personalCertStore')->name('member.personalCertStore'); // 个人认证
    Route::get('member/enterpriseCert', 'MemberController@enterpriseCert')->name('member.enterpriseCert'); // 企业认证
    Route::post('member/enterpriseCert', 'MemberController@enterpriseCertStore')->name('member.enterpriseCertStore'); // 企业认证
    
    // 提现
    Route::get('member/withdrawal', 'WithdrawalController@index')->name('withdrawal.index');
    Route::get('member/withdrawal/cash', 'WithdrawalController@cash')->name('withdrawal.cash');
    Route::get('member/withdrawal/history', 'WithdrawalController@history')->name('withdrawal.history');
    
    // 后台账号
    Route::get('member/account', 'MemberController@account')->name('member.account');
    Route::post('member/accountStore', 'MemberController@accountStore')->name('member.accountStore');

    // 订单
    Route::get('order/{id}', 'OrderController@show')->name('order.show');
    Route::post('order/create', 'OrderController@haddleCreate')->name('order.create');
    Route::post('order/cancle/{id}', 'OrderController@cancle')->name('order.cancle');
    Route::delete('order/{id}', 'OrderController@destroy')->name('order.destroy');
    Route::post('order/{id}/confirm', 'OrderController@confirm')->name('order.confirm');
    Route::post('order/{id}/receive', 'OrderController@receive')->name('order.receive');
    Route::post('order/{id}/delivering', 'OrderController@delivering')->name('order.delivering');
    
    // 地址
    Route::get('address', 'UserAddressController@index')->name('uaddress');
    Route::get('address/create', 'UserAddressController@create')->name('uaddress.create');
    Route::get('address/{id}/edit', 'UserAddressController@edit')->name('uaddress.edit');

    Route::get('address/{id}', 'UserAddressController@show')->name('uaddress.show');
    Route::post('address', 'UserAddressController@store')->name('uaddress.store');
    Route::post('address/{id}/update', 'UserAddressController@update')->name('uaddress.update');
    Route::post('address/{id}/delete', 'UserAddressController@destroy')->name('uaddress.destroy');
    Route::get('address/default', 'UserAddressController@showDefault')->name('uaddress.default'); // 默认地址
    Route::post('address/setDefault', 'UserAddressController@setDefault')->name('uaddress.setDefault'); // 默认地址

    // 自营店
    Route::get('self-support', 'SelfSupportController@index')->name('self-support.index');

    // 其他
    Route::get('public/verification', 'PublicController@phoneVerification')->name('public.phoneVerification');
    Route::post('public/verification', 'PublicController@phoneVerification')->name('public.phoneVerification');
    Route::post('public/sendSms', 'PublicController@sendSms')->name('public.sendSms');
    Route::post('public/upload', 'PublicController@upload')->name('public.upload'); // 上传图片 
});

Route::any('payment/wxpay/notify', 'Front\PaymentController@wxpayNotify')->name('payment.wxpayNotify'); // 支付回调
Route::any('district/{adcode}/{level}/{subdistrict}', 'RegionController@district')->name('district');